package com.demo.util;

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 时间转换工具类
 *
 * @author ：zm
 * @date ：2020-10-10
 */
@Slf4j
public class TimeUtil {

    /**
     * 获取当前秒级时间戳(10位)
     *
     * @return
     */
    public static String getSecondsTimeStampStr() {
        Long secondsTimeStamp = System.currentTimeMillis() / 1000L;
        return secondsTimeStamp.toString();
    }

    /**
     * 获取当前秒级时间戳(10位)
     *
     * @return
     */
    public static Integer getSecondsTimeStamp() {
        Long secondsTimeStamp = System.currentTimeMillis() / 1000L;
        return secondsTimeStamp.intValue();
    }

    /**
     * 秒级时间戳(10位)转成日期和时间字符串（年-月-日 小时：分钟：秒）
     *
     * @param secondsTimeStamp 秒级时间戳(10位)字符串
     */
    public static String secondsTimeStampToDateAndTimeString(String secondsTimeStamp) {
        if (secondsTimeStamp == null) {
            return null;
        }
        long secondsTimeStampLong = Long.parseLong(secondsTimeStamp);
        Timestamp timestamp = new Timestamp(secondsTimeStampLong * 1000);
        Date date = new Date(timestamp.getTime());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(date);
    }

    /**
     * 秒级时间戳(10位)转成日期和时间字符串（年-月-日 小时：分钟：秒）
     *
     * @param secondsTimeStamp 秒级时间戳(10位)字符串
     */
    public static String secondsTimeStampToDateAndTimeString(Integer secondsTimeStamp) {
        if (secondsTimeStamp == null) {
            return null;
        }
        long secondsTimeStampLong = new Long(secondsTimeStamp);
        Timestamp timestamp = new Timestamp(secondsTimeStampLong * 1000);
        Date date = new Date(timestamp.getTime());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(date);
    }

    /**
     * 秒级时间戳(10位)转成日期和时间Date类（年-月-日 小时：分钟：秒）
     *
     * @param secondsTimeStamp 秒级时间戳(10位)
     */
    public static Date secondsTimeStampToDateAndTimeDate(Integer secondsTimeStamp) {
        if (secondsTimeStamp == null) {
            return null;
        }
        long secondsTimeStampLong = new Long(secondsTimeStamp);
        Timestamp timestamp = new Timestamp(secondsTimeStampLong * 1000);
        Date date = new Date(timestamp.getTime());
        return date;
    }

    /**
     * 秒级时间戳(10位)转成日期（年-月-日）字符串
     *
     * @param secondsTimeStamp 秒级时间戳(10位)字符串
     */
    public static String secondsTimeStampToDateString(String secondsTimeStamp) {
        if (secondsTimeStamp == null) {
            return null;
        }
        long secondsTimeStampLong = Long.parseLong(secondsTimeStamp);
        Date date = new Date(secondsTimeStampLong * 1000);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        return format.format(date);
    }

    /**
     * 通过时间字符串 计算时间戳
     *
     * @param dateStr
     * @return
     * @throws Exception
     */
    public static Integer getTimeStampByDateStr(String dateStr) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return new Long(format.parse(dateStr).getTime() / 1000L).intValue();
    }

    /**
     * 获取 当前年、半年、季度、月、日、小时 开始结束时间
     */

    private final static SimpleDateFormat shortSdf = new SimpleDateFormat("yyyy-MM-dd");
    private final static SimpleDateFormat longHourSdf = new SimpleDateFormat("yyyy-MM-dd HH");
    ;
    private final static SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    ;


    /**
     * 获得本周的第一天，周一
     *
     * @return
     */
    public static Date getCurrentWeekDayStartTime() {
        Calendar curStartCal = Calendar.getInstance();
        Calendar cal = (Calendar) curStartCal.clone();
        try {
            cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            //String firstDay = shortSdf.format(cal.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return cal.getTime();
    }

    /**
     * 获得本周的最后一天，周日
     *
     * @return
     */
    public static Date getCurrentWeekDayEndTime() {
        Calendar curStartCal = Calendar.getInstance();
        Calendar cal = (Calendar) curStartCal.clone();
        try {
            cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            // String firstDay = shortSdf.format(cal.getTime());
            cal.add(Calendar.DATE, 6);
            //String lastDay = shortSdf.format(cal.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return cal.getTime();
    }

    /**
     * 获得本天的开始时间
     *
     * @return
     */
    public static Date getCurrentDayStartTime() {
        Date now = new Date();
        try {
            now = shortSdf.parse(shortSdf.format(now));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 获得本天的结束时间
     *
     * @return
     */
    public static Date getCurrentDayEndTime() {
        Date now = new Date();
        try {
            now = longSdf.parse(shortSdf.format(now) + " 23:59:59");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 获得本小时的开始时间
     *
     * @return
     */
    public static Date getCurrentHourStartTime() {
        Date now = new Date();
        try {
            now = longHourSdf.parse(longHourSdf.format(now));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }


    /**
     * 获得本小时的结束时间
     *
     * @return
     */
    public static Date getCurrentHourEndTime() {
        Date now = new Date();
        try {
            now = longSdf.parse(longHourSdf.format(now) + ":59:59");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 获得本月的开始时间
     *
     * @return
     */
    public static Date getCurrentMonthStartTime() {
        Calendar c = Calendar.getInstance();
        Date now = null;
        try {
            c.set(Calendar.DATE, 1);
            now = shortSdf.parse(shortSdf.format(c.getTime()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 本月的结束时间
     *
     * @return
     */
    public static Date getCurrentMonthEndTime() {
        Calendar c = Calendar.getInstance();
        Date now = null;
        try {
            c.set(Calendar.DATE, 1);
            c.add(Calendar.MONTH, 1);
            c.add(Calendar.DATE, -1);
            now = longSdf.parse(shortSdf.format(c.getTime()) + " 23:59:59");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 当前年的开始时间
     *
     * @return
     */
    public static Date getCurrentYearStartTime() {
        Calendar c = Calendar.getInstance();
        Date now = null;
        try {
            c.set(Calendar.MONTH, 0);
            c.set(Calendar.DATE, 1);
            now = shortSdf.parse(shortSdf.format(c.getTime()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 当前年的结束时间
     *
     * @return
     */
    public static Date getCurrentYearEndTime() {
        Calendar c = Calendar.getInstance();
        Date now = null;
        try {
            c.set(Calendar.MONTH, 11);
            c.set(Calendar.DATE, 31);
            now = longSdf.parse(shortSdf.format(c.getTime()) + " 23:59:59");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 当前季度的开始时间
     *
     * @return
     */
    public static Date getCurrentQuarterStartTime() {
        Calendar c = Calendar.getInstance();
        int currentMonth = c.get(Calendar.MONTH) + 1;
        Date now = null;
        try {
            if (currentMonth >= 1 && currentMonth <= 3)
                c.set(Calendar.MONTH, 0);
            else if (currentMonth >= 4 && currentMonth <= 6)
                c.set(Calendar.MONTH, 3);
            else if (currentMonth >= 7 && currentMonth <= 9)
                c.set(Calendar.MONTH, 4);
            else if (currentMonth >= 10 && currentMonth <= 12)
                c.set(Calendar.MONTH, 9);
            c.set(Calendar.DATE, 1);
            now = longSdf.parse(shortSdf.format(c.getTime()) + " 00:00:00");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 当前季度的结束时间
     *
     * @return
     */
    public static Date getCurrentQuarterEndTime() {
        Calendar c = Calendar.getInstance();
        int currentMonth = c.get(Calendar.MONTH) + 1;
        Date now = null;
        try {
            if (currentMonth >= 1 && currentMonth <= 3) {
                c.set(Calendar.MONTH, 2);
                c.set(Calendar.DATE, 31);
            } else if (currentMonth >= 4 && currentMonth <= 6) {
                c.set(Calendar.MONTH, 5);
                c.set(Calendar.DATE, 30);
            } else if (currentMonth >= 7 && currentMonth <= 9) {
                c.set(Calendar.MONTH, 8);
                c.set(Calendar.DATE, 30);
            } else if (currentMonth >= 10 && currentMonth <= 12) {
                c.set(Calendar.MONTH, 11);
                c.set(Calendar.DATE, 31);
            }
            now = longSdf.parse(shortSdf.format(c.getTime()) + " 23:59:59");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 获取前/后半年的开始时间
     *
     * @return
     */
    public static Date getHalfYearStartTime() {
        Calendar c = Calendar.getInstance();
        int currentMonth = c.get(Calendar.MONTH) + 1;
        Date now = null;
        try {
            if (currentMonth >= 1 && currentMonth <= 6) {
                c.set(Calendar.MONTH, 0);
            } else if (currentMonth >= 7 && currentMonth <= 12) {
                c.set(Calendar.MONTH, 6);
            }
            c.set(Calendar.DATE, 1);
            now = longSdf.parse(shortSdf.format(c.getTime()) + " 00:00:00");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;

    }

    /**
     * 获取前/后半年的结束时间
     *
     * @return
     */
    public static Date getHalfYearEndTime() {
        Calendar c = Calendar.getInstance();
        int currentMonth = c.get(Calendar.MONTH) + 1;
        Date now = null;
        try {
             /*   if (currentMonth >= 1 && currentMonth <= 6) {
                    c.set(Calendar.MONTH, 5);
                    c.set(Calendar.DATE, 30);
                } else if (currentMonth >= 7 && currentMonth <= 12) {
                    c.set(Calendar.MONTH, 11);
                    c.set(Calendar.DATE, 31);
                }*/
            if (currentMonth >= 1 && currentMonth <= 6) {
                c.set(Calendar.MONTH, 11);
                c.set(Calendar.DATE, 31);

            } else if (currentMonth >= 7 && currentMonth <= 12) {
                c.set(Calendar.MONTH, 5);
                c.set(Calendar.DATE, 30);
            }
            now = longSdf.parse(shortSdf.format(c.getTime()) + " 23:59:59");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }


    /**
     * 获取当前时间6个月之前
     *
     * @return
     */
    public static String getSexMonthBefore(String nowTime) throws ParseException, ParseException {
        // 获取当前时间
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = dateFormat.parse(nowTime);
        Calendar calendar = Calendar.getInstance(); //得到日历
        calendar.setTime(date);//把当前时间赋给日历
        calendar.add(calendar.MONTH, -6); //设置为前2月，可根据需求进行修改
        date = calendar.getTime();//获取2个月前的时间
        return dateFormat.format(date);

    }


    /**
     * 获取本周的第一天
     *
     * @return String
     **/
    public static String getWeekStart() {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.WEEK_OF_MONTH, 0);
        cal.set(Calendar.DAY_OF_WEEK, 2);
        Date time = cal.getTime();
        return new SimpleDateFormat("yyyy-MM-dd").format(time) + " 00:00:00";
    }

    /**
     * 获取本周的最后一天
     *
     * @return String
     **/
    public static String getWeekEnd() {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.DAY_OF_WEEK, cal.getActualMaximum(Calendar.DAY_OF_WEEK));
        cal.add(Calendar.DAY_OF_WEEK, 1);
        Date time = cal.getTime();
        return new SimpleDateFormat("yyyy-MM-dd").format(time) + " 23:59:59";
    }


    /**
     * 查询当前时间之后的N天
     *
     * @param value 时间天数：2
     * @return 示例：2020-12-26 15:15:15     返回：2020-12-27 15:15:15
     */
    public static Date getAfterDay(Integer value) {
        Calendar calendar1 = Calendar.getInstance();
        calendar1.add(Calendar.DATE, value);
        Date date = calendar1.getTime();
        return date;
    }

    /**
     * 查询当前时间之前的N天
     *
     * @param value 时间天数：2
     * @return 示例：2020-12-26 15:15:15     返回：2020-12-25 15:15:15
     */
    public static Date getBoforeDay(Integer value) {
        Calendar calendar1 = Calendar.getInstance();
        calendar1.add(Calendar.DATE, -value);
        Date date = calendar1.getTime();
        return date;
    }

    /**
     * 当前时间的下一天【自定义几点】
     *
     * @return
     */
    public static Date getSpecifiedDayAfter() {
        String format = DateUtil.format(DateUtil.tomorrow(), "yyyy/MM/dd") + " 09:00:00";
        return DateUtil.parse(format);
    }


    /**
     * 获取指定时间+指定小时后的时间
     *
     * @param date  指定时间
     * @param value +指定小时后h
     * @return
     */
    public static Date getSpecifyTimeAfter(Date date, int value) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.HOUR, 72);
        //c.add(Calendar.MINUTE, 59); //日期分钟加59分钟
        //c.add(Calendar.SECOND, 59); //日期分钟加59分钟
        Date d = c.getTime();
        return d;
    }

    /**
     * 获取当前时间6个月之前
     * @return
     */
//    public static String getSexMonthBefore(String nowTime) throws ParseException, ParseException {
//        // 获取当前时间
//        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        Date date=dateFormat.parse(nowTime);
//        Calendar calendar = Calendar.getInstance(); //得到日历
//        calendar.setTime(date);//把当前时间赋给日历
//        calendar.add(calendar.MONTH, -6); //设置为前2月，可根据需求进行修改
//        date = calendar.getTime();//获取2个月前的时间
//        return dateFormat.format(date);
//
//    }

    /**
     * 获取当前时间[某个月]个月之前的时间节点   示例：2020-10-13   返回：2020-09-13
     *
     * @return
     */
    public static String getMonthBefore(String nowTime, Integer month) throws ParseException, ParseException {
        // 获取当前时间
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = dateFormat.parse(nowTime);
        Calendar calendar = Calendar.getInstance(); //得到日历
        calendar.setTime(date);//把当前时间赋给日历
        calendar.add(calendar.MONTH, -month); //设置为前2月，可根据需求进行修改
        date = calendar.getTime();//获取2个月前的时间
        return dateFormat.format(date);

    }

    /**
     * 获取指定年份+指定月份的的第一天开始时间
     *
     * @return
     */
    public static String getMonthBeforeStartTime(Integer year, Integer month) {
        Calendar cal = Calendar.getInstance();
        //设置年份
        cal.set(Calendar.YEAR, year);
        //设置月份
        cal.set(Calendar.MONTH, month - 1);
        //获取某月最小天数
        int firstDay = cal.getMinimum(Calendar.DATE);
        //设置日历中月份的最小天数
        cal.set(Calendar.DAY_OF_MONTH, firstDay);
        //格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(cal.getTime());
    }

    /**
     * 获取指定年份+指定月份的的最后一天结束时间
     *
     * @return
     */
    public static String getMonthBeforeEndTime(Integer year, Integer month) {
        Calendar cal = Calendar.getInstance();
        //设置年份
        cal.set(Calendar.YEAR, year);
        //设置月份
        cal.set(Calendar.MONTH, month - 1);
        //获取某月最大天数
        int firstDay = cal.getMaximum(Calendar.DATE);
        if (month == 2 || month == 4 || month == 6 || month == 9 || month == 11) {
            firstDay = firstDay - 1;
        }
        //设置日历中月份的最大天数
        cal.set(Calendar.DAY_OF_MONTH, firstDay);
        //格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(cal.getTime());
    }


    /**
     * 将时间对象转换为10位时间戳
     *
     * @param date 时间对象
     * @return
     */
    public static Integer getTimestamp(Date date) {
        Long time = date.getTime() / 1000;
        return Integer.parseInt(time.toString());
    }

    /**
     * 获取月份的第一天
     *
     * @param month
     * @return
     */
    public static String getFirstDayOfMonth(int month) {
        Calendar cal = Calendar.getInstance();
        // 设置月份
        cal.set(Calendar.MONTH, month - 1);
        // 获取某月最小天数
        int firstDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
        // 设置日历中月份的最小天数
        cal.set(Calendar.DAY_OF_MONTH, firstDay);
        // 格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String firstDayOfMonth = sdf.format(cal.getTime()) + " 00:00:00";
        return firstDayOfMonth;
    }

    /**
     * 获得该月最后一天
     *
     * @param
     * @param month
     * @return
     */
    public static String getLastDayOfMonth(int month) {
        Calendar cal = Calendar.getInstance();
        // 设置月份
        cal.set(Calendar.MONTH, month - 1);
        // 获取某月最大天数
        int lastDay = 0;
        //2月的平年瑞年天数
        if (month == 2) {
            lastDay = cal.getLeastMaximum(Calendar.DAY_OF_MONTH);
        } else {
            lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        }
        // 设置日历中月份的最大天数
        cal.set(Calendar.DAY_OF_MONTH, lastDay);
        // 格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String lastDayOfMonth = sdf.format(cal.getTime()) + " 23:59:59";
        return lastDayOfMonth;
    }

    /**
     * 转换上一年【月份开始】
     *
     * @param date
     * @return
     */
    public static Date monthsFirstTime(Date date) {
        Date startDate = DateUtil.parse(TimeUtil.getFirstDayOfMonth(12));
        int a = DateUtil.year(startDate);
        int b = DateUtil.month(startDate) + 1;
        String cc = a - 1 + "-" + b + "-" + "01" + " 00:00:00";
        Date date2 = DateUtil.parse(cc);
        return date2;
    }

    /**
     * 转换上一年【月份结束】
     *
     * @param date
     * @return
     */
    public static Date monthsLastTime(Date date) {
        Date startDate = DateUtil.parse(TimeUtil.getFirstDayOfMonth(12));
        int a = DateUtil.year(startDate);
        int b = DateUtil.month(startDate) + 1;
        String cc = a - 1 + "-" + b + "-" + "30" + " 00:00:00";
        Date date2 = DateUtil.parse(cc);
        return date2;
    }

    /**
     * 获取两个年份之间的所有年份
     *
     * @param minYear
     * @param maxYear
     * @return
     * @throws ParseException
     */
    public static List<Integer> getYear(String minYear, String maxYear) {
        Integer str1 = Integer.parseInt(minYear);
        Integer str2 = Integer.parseInt(maxYear);
        String str4 = "";
        for (int i = str1; i < str2; i++) {
            str4 += i + ",";
        }
        str4 = str4 + str2;
        log.info(str4);
        String[] year = str4.split(",");
        List<Integer> yrars = new ArrayList<>();
        for (String s : year) {
            yrars.add(Integer.parseInt(s));
        }
        return yrars;
    }


    /**
     * 获取某年第一天日期
     *
     * @param year 年份
     * @return Date
     */
    public static Date getYearFirst(int year) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(Calendar.YEAR, year);
        Date currYearFirst = calendar.getTime();
        Date date = DateUtil.parse(format.format(currYearFirst));
        return date;
    }

    /**
     * 获取某年最后一天日期
     *
     * @param year 年份
     * @return Date
     */
    public static Date getYearLast(int year) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(Calendar.YEAR, year);
        calendar.roll(Calendar.DAY_OF_YEAR, -1);
        Date currYearLast = calendar.getTime();
        //使用了工具类
        String date = DateUtil.format(currYearLast, "yyyy-MM-dd") + " 23:59:59";
        return DateUtil.parse(date);
    }

    /**
     * 根据季度，获取季度开始的第一天与结束的最后一天
     *
     * @param QuarterlyId
     * @return
     */
    public static Map<String, Date> getQuarterlyStartAndEndTime(Integer QuarterlyId) {
        Map<String, Date> map = new HashMap<>();
        if (QuarterlyId.equals(1)) {
            map.put("startTime", DateUtil.parse(TimeUtil.getFirstDayOfMonth(1)));
            map.put("endTime", DateUtil.parse(TimeUtil.getLastDayOfMonth(3)));
        }
        if (QuarterlyId.equals(2)) {
            map.put("startTime", DateUtil.parse(TimeUtil.getFirstDayOfMonth(4)));
            map.put("endTime", DateUtil.parse(TimeUtil.getLastDayOfMonth(6)));
        }
        if (QuarterlyId.equals(3)) {
            map.put("startTime", DateUtil.parse(TimeUtil.getFirstDayOfMonth(7)));
            map.put("endTime", DateUtil.parse(TimeUtil.getLastDayOfMonth(9)));
        }
        if (QuarterlyId.equals(4)) {
            map.put("startTime", DateUtil.parse(TimeUtil.getFirstDayOfMonth(10)));
            map.put("endTime", DateUtil.parse(TimeUtil.getLastDayOfMonth(12)));
        }
        return map;
    }

    /**
     * 通过当前时间，获取往后推算的最近6个月
     *
     * @return
     */
    public static List<Integer> getMonthSex(Integer monthDate) {
        List<Integer> months = new ArrayList<>();

        Calendar date = Calendar.getInstance();
        int month = date.get(Calendar.MONTH) + 1;//获取当前日期的月份
        int[] a = new int[6];
        for (int i = 1; i <= a.length; i++) {
            if (month > 6) {
                //当前月份大于6月
                a[i - 1] = (month - 6 + i);
            } else {
                //当前月份小于等于6月
                if (month - i < 0) {
                    a[a.length - i] = (month - i + 13);
                } else {
                    a[a.length - i] = (month - i + 1);
                }
            }

        }
        for (Integer number : a) {
            months.add(number);
        }
        log.info("最后返回的月份集合" + months);
        return months;
    }


    /**
     * 设置微信二维码失效时间，并返回具体失效的时间点
     *
     * @param expire 二维码的有效时间，单位是毫秒
     * @return
     */
    public static String getOrderExpireTime(Long expire) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        Date now = new Date();
        Date afterDate = new Date(now.getTime() + expire);
        return sdf.format(afterDate);
    }

    public static boolean isString(String str) {
        if (str != null && !"".equals(str)) {
            return true;
        }
        return false;
    }

}
